Skip to main content

Text-to-Speech API

Endpoint /tts

https://api.botlhale.xyz/tts
tip

You need to include an Authentication Token in request headers. See the Authentication page of this documentation for information on how to generate authentication token codes.

Method: POST

This endpoint handles Text-to-Speech (TTS) requests by converting input text into synthesized speech. The request is processed by an external TTS service, and the response includes a URL to the generated audio file along with the sampling rate.

Authentication

A valid Bearer token must be included in the request headers.

Headers:

  • Authorization: Bearer <your_token>

Form Arguments

Request ParamsData TypeDescription
textstringRequiredThe text to be converted into speech.
language_codestringRequiredThe language code specifying the language for speech synthesis

Response body

The API returns a JSON object containing the audio URL and additional details about the request.#

Example Response:

Unset
{
"audio_url": "https://s3-bucket-url.com/tts/audio_123456.mp3",
"language_code": "en-US",
"text": "Hello, how are you?",
"sampling_rate": 22050,
"date_received": "2025-01-28T10:00:00Z"
}

Response Fields:

Request ParamsData TypeDescription
audio_urstringThe URL where the synthesized speech file can be accessed.
language_codestringThe language code used for synthesis.
textstringThe original input text.
sampling_ratestringThe sample rate of the generated audio in hertz.
date_receivedstringThe date and time when the request was processed, in ISO 8601 format.

Supported Languages

The following table shows the languages Botlhale AI currently supports. The table also indicates the speech tasks supported for each language. Our team is always working to add new languages to the list.

LanguageRegionCodeTranslationASRTTSDiarizationLanguage ID
EnglishSouth Africaen-ZA
isiZuluSouth Africazu-ZA
isiXhosaSouth Africaxh-ZA
SesothoSouth Africast-ZA-
SetswanaSouth Africatn-ZA
SepediSouth Africanso-ZA
TshivendaSouth Africavr-ZA-
XitsongaSouth Africats-ZA-
AfrikaansSouth Africaaf-ZA
KiswahiliKenyasw-KE-
KinyarwandaRwandarw-RW---

Request Example

import requests

url = "https://api-dev.botlhale.xyz/tts"

payload = {'LanguageCode': 'xh-ZA',
'text_msg': 'Xa ufuna ukuthenga imoto cofa iqhosha lokuqala.'}
files=[

]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

Response body

{
"date_received": "09/03/2023 11:18:09",
"language_code": "IsiXhosa",
"speech_responseURL": "<SpeechResponseURL>",
"text_msg": "Xa ufuna ukuthenga imoto cofa iqhosha lokuqala."
}

Contact us

info

We are here to help! Please contact us with any questions.